<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  
  <meta name="description" content="首次安装配置1234567// 查看全局配置    git config --list // 配置全局邮箱    git config --global user.email &amp;quot;你的邮箱&amp;quot;// 配置全局用户名    git config --global user.name &amp;q" />
  

  
  
  
  
  
  
  <title>git基本操作 | 疯子-百炼成仙</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="首次安装配置1234567&#x2F;&#x2F; 查看全局配置    git config --list &#x2F;&#x2F; 配置全局邮箱    git config --global user.email &quot;你的邮箱&quot;&#x2F;&#x2F; 配置全局用户名    git config --global user.name &quot;你的用户名&quot; 上传到远程12# 添加一个远程仓库地址    git remote">
<meta property="og:type" content="article">
<meta property="og:title" content="git基本操作">
<meta property="og:url" content="http://example.com/2023/03/21/git%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C/index.html">
<meta property="og:site_name" content="疯子-百炼成仙">
<meta property="og:description" content="首次安装配置1234567&#x2F;&#x2F; 查看全局配置    git config --list &#x2F;&#x2F; 配置全局邮箱    git config --global user.email &quot;你的邮箱&quot;&#x2F;&#x2F; 配置全局用户名    git config --global user.name &quot;你的用户名&quot; 上传到远程12# 添加一个远程仓库地址    git remote">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-03-21T09:28:02.000Z">
<meta property="article:modified_time" content="2023-03-22T06:08:13.536Z">
<meta property="article:author" content="Haung lixi">
<meta name="twitter:card" content="summary">
  
  
    <link rel="icon" href="/css/images/favicon.ico">
  
  
<link rel="stylesheet" href="/css/style.css">

  

  
  <!-- baidu webmaster push -->
  <script src='//push.zhanzhang.baidu.com/push.js'></script>
<meta name="generator" content="Hexo 5.4.2"></head>
<body class="home blog custom-background custom-font-enabled single-author">
  <div id="page" class="hfeed site">
      <header id="masthead" class="site-header" role="banner">
    <hgroup>
      <h1 class="site-title">
        <a href="/" title="疯子-百炼成仙" rel="home">疯子-百炼成仙</a>
      </h1>
      
        <h2 class="site-description hitokoto"></h2>
        <script type="text/javascript" src="https://v1.hitokoto.cn/?encode=js"></script>
      
    </hgroup>

    <nav id="site-navigation" class="main-navigation" role="navigation">
            <button class="menu-toggle">菜单</button>
            <a class="assistive-text" href="/#content" title="跳至内容">跳至内容</a><!--TODO-->
            <div class="menu-main-container">
                <ul id="menu-main" class="nav-menu">
                
                    <li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="/">Home</a></li>
                
                    <li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="/archives">Archives</a></li>
                
                </ul>
            </div>
    </nav>
</header>

      <div id="main" class="wrapper">
        <div id="primary" class="site-content"><div id="content" role="main"><article id="post-git基本操作" class="post-git基本操作 post type-post status-publish format-standard hentry">
    <!---->

      <header class="entry-header">
        
        
  
    <h1 class="entry-title article-title">
      git基本操作
    </h1>
  

        
        <div class="comments-link">
            
            <a href="javascript:void(0);" data-url="http://example.com/2023/03/21/git%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C/" data-id="clfjc2gla00007kw12mvdd3w2" class="leave-reply bdsharebuttonbox" data-cmd="more">Share</a>
        </div><!-- .comments-link -->
      </header><!-- .entry-header -->

    <div class="entry-content">
      
        <h3 id="首次安装配置"><a href="#首次安装配置" class="headerlink" title="首次安装配置"></a>首次安装配置</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 查看全局配置</span></span><br><span class="line">    git config --list</span><br><span class="line"> </span><br><span class="line"><span class="comment">// 配置全局邮箱</span></span><br><span class="line">    git config --<span class="variable language_">global</span> user.<span class="property">email</span> <span class="string">&quot;你的邮箱&quot;</span></span><br><span class="line"><span class="comment">// 配置全局用户名</span></span><br><span class="line">    git config --<span class="variable language_">global</span> user.<span class="property">name</span> <span class="string">&quot;你的用户名&quot;</span></span><br></pre></td></tr></table></figure>
<h3 id="上传到远程"><a href="#上传到远程" class="headerlink" title="上传到远程"></a>上传到远程</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># 添加一个远程仓库地址</span><br><span class="line">    git remote add origin  你的仓库地址</span><br></pre></td></tr></table></figure>
<h3 id="git忽略文件"><a href="#git忽略文件" class="headerlink" title="git忽略文件"></a>git忽略文件</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.<span class="property">gitignore</span>   <span class="comment">// 忽略文件</span></span><br></pre></td></tr></table></figure>
<h3 id="git分支"><a href="#git分支" class="headerlink" title="git分支"></a>git分支</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"># 创建分支</span><br><span class="line">    git branch 分支名</span><br><span class="line"># 查看分支</span><br><span class="line">    git branch</span><br><span class="line"># 切换分支</span><br><span class="line">    git checkout 分支名</span><br><span class="line"># 合并分支</span><br><span class="line">    git merge 分支名</span><br><span class="line"># 删除分支</span><br><span class="line">    git branch -d 分支名</span><br><span class="line"></span><br><span class="line"># 远程分支的操作</span><br><span class="line">    git push origin 分支名    <span class="comment">// 自定义分支的内容上传</span></span><br><span class="line">    git push origin --<span class="keyword">delete</span> 分支名    <span class="comment">// 删除远程分支</span></span><br><span class="line">    </span><br></pre></td></tr></table></figure>
<h3 id="分支的命名规范"><a href="#分支的命名规范" class="headerlink" title="分支的命名规范"></a>分支的命名规范</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"># <span class="number">1.</span>主分支 - <span class="function"><span class="params">master</span></span></span><br><span class="line"><span class="function">    =&gt;</span> 不接受任何代码上传</span><br><span class="line">    =&gt; 只接受 dev 分支合并的内容</span><br><span class="line">    </span><br><span class="line"># <span class="number">2.</span>主开发分支 - dev/development/<span class="function"><span class="params">deve</span></span></span><br><span class="line"><span class="function">    =&gt;</span> 初始化项目以后，在 master 上开辟的分支</span><br><span class="line">    =&gt; 不接受任何代码上传</span><br><span class="line">    =&gt; 只接受 主功能分支 合并的内容</span><br><span class="line">    </span><br><span class="line"># <span class="number">3.</span>主功能分支 - feature-xxx</span><br><span class="line"></span><br><span class="line"># <span class="number">4.</span>功能 bug 解决分支 - feature-xxx-fix-xxx</span><br><span class="line"></span><br><span class="line"># <span class="number">5.</span>紧急 bug 解决 - hot-fix-<span class="function"><span class="params">xxx</span></span></span><br><span class="line"><span class="function">    =&gt;</span> 直接从 master 上开辟</span><br><span class="line">    =&gt; 修复完毕以后,直接合并到 master 上</span><br></pre></td></tr></table></figure>

<h4 id="1-远程仓库拉去代码"><a href="#1-远程仓库拉去代码" class="headerlink" title="1. 远程仓库拉去代码"></a>1. 远程仓库拉去代码</h4><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 第一次下载（克隆）代码</span></span><br><span class="line">    git clone 仓库地址</span><br><span class="line"></span><br><span class="line"><span class="comment">// 第二次 拉取 代码</span></span><br><span class="line">    git pull 仓库地址</span><br><span class="line"></span><br><span class="line"><span class="comment">// 提交代码步骤</span></span><br><span class="line">    git add ./     </span><br><span class="line">    git commit -m<span class="string">&quot;描述信息&quot;</span></span><br><span class="line">    git push </span><br></pre></td></tr></table></figure>

<h4 id="2-更换远程仓库地址"><a href="#2-更换远程仓库地址" class="headerlink" title="2. 更换远程仓库地址"></a>2. 更换远程仓库地址</h4><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git remote -v              <span class="comment">// 查看当前地址  </span></span><br><span class="line">git remote rm origin       <span class="comment">// 删除当前地址</span></span><br><span class="line">git remote add origin <span class="title class_">URl</span>  <span class="comment">// 新增地址 </span></span><br></pre></td></tr></table></figure>


<h4 id="3-commit-描述信息规范"><a href="#3-commit-描述信息规范" class="headerlink" title="3. commit 描述信息规范"></a>3. commit 描述信息规范</h4><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git -commit -m<span class="string">&quot;feat：注册功能完成&quot;</span>          <span class="comment">// feat：新功能  </span></span><br><span class="line">git -commit -m<span class="string">&quot;fix：修复登录表单验证bug&quot;</span>    <span class="comment">// fix：修补bug  </span></span><br><span class="line">git -commit -m<span class="string">&quot;docs：新增功能文档&quot;</span>          <span class="comment">// docs：文档   </span></span><br></pre></td></tr></table></figure>

<h4 id="4-git其他命令"><a href="#4-git其他命令" class="headerlink" title="4. git其他命令"></a>4. git其他命令</h4><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">git init      <span class="comment">// 初始化</span></span><br><span class="line">git status    <span class="comment">// 查看仓库状态</span></span><br><span class="line"></span><br><span class="line">git reset <span class="variable constant_">HEAD</span> -- 文件名  <span class="comment">// 暂存区撤回内容</span></span><br><span class="line">git reset <span class="variable constant_">HEAD</span> -- 文件夹名称  <span class="comment">// 暂存区撤回内容</span></span><br><span class="line">git reset <span class="variable constant_">HEAD</span> -- .  <span class="comment">// 暂存区撤回所有内容</span></span><br><span class="line"></span><br><span class="line">git log   <span class="comment">// 查看历史版本</span></span><br><span class="line">git reset --hard 版本id  <span class="comment">// 回滚历史版本</span></span><br><span class="line"></span><br><span class="line">git tag -a v1<span class="number">.1</span> -m <span class="string">&quot;test_tag&quot;</span>；  <span class="comment">// 打标签</span></span><br><span class="line">git config --<span class="variable language_">global</span> http.<span class="property">sslVerify</span> <span class="string">&quot;false&quot;</span>  <span class="comment">//解除ssl验证</span></span><br></pre></td></tr></table></figure>
<h4 id="配置-Git-密钥"><a href="#配置-Git-密钥" class="headerlink" title="配置 Git 密钥"></a>配置 Git 密钥</h4><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> 输入指令 ssh-keygen -t rsa -C <span class="string">&quot;你Git工具的全局邮箱&quot;</span></span><br><span class="line"><span class="number">2.</span> “我的电脑” 找到密钥 -&gt; pub文件 -&gt; 复制全本</span><br><span class="line"><span class="number">3.</span> github -&gt; settings -&gt; 选择<span class="variable constant_">SSH</span> -&gt; 点击<span class="variable constant_">SSH</span> key 后面的 <span class="keyword">new</span> <span class="variable constant_">SSH</span> key -&gt; title 位置随便写 -&gt; key 的位置填写复制下来的密钥</span><br></pre></td></tr></table></figure>

      
    </div><!-- .entry-content -->

    <footer class="entry-meta">
    <a href="/2023/03/21/git%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C/">
    <time datetime="2023-03-21T09:28:02.000Z" class="entry-date">
        2023-03-21
    </time>
</a>
    
    
    </footer>
</article>


    
<nav class="nav-single">
    <h3 class="assistive-text">文章导航</h3>
    
        <span class="nav-previous"><a href="/2023/03/22/%E6%9C%AC%E5%9C%B0%E5%9B%BE%E7%89%87/" rel="prev"><span class="meta-nav">←</span> 本地图片</a></span>
    
    
</nav><!-- .nav-single -->







</div></div>
        <div id="secondary" class="widget-area" role="complementary">
  
    <aside id="search" class="widget widget_search"><form role="search" method="get" accept-charset="utf-8" id="searchform" class="searchform" action="//google.com/search">
    <div>
        <input type="text" value="" name="s" id="s" />
        <input type="submit" id="searchsubmit" value="搜索" />
    </div>
</form></aside>
  
    <!-- 
  <aside class="widget">
    <h3 class="widget-title">Music</h3>
    <div class="widget-content">
      <audio src="src=&#34;//music.163.com/outchain/player?type=2&amp;id=1950343972&amp;auto=1&amp;height=32&#34;" controls="controls"
             style="width:100%">
        您的浏览器不支持 audio 标签。
      </audio>
    </div>
  </aside>
 -->

<!--去[网易云音乐](https://music.163.com/)搜索喜欢的音乐，点击生成外链播放器， 复制代码直接放到博文末尾即可，
height设为0可隐藏播放器，但仍然可以播放音乐，auto设成0可手动播放，默认是1自动播放。-->


  <aside class="widget">
    <h3 class="widget-title">Music</h3>
    <div class="widget-content">
      <!-- <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=100% height=52 
      src="src=&#34;//music.163.com/outchain/player?type=2&amp;id=1950343972&amp;auto=1&amp;height=32&#34;"></iframe> -->
      <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=1950343972&auto=1&height=66"></iframe>
    </div>
  </aside>



  
    
  
    
  <aside class="widget">
    <h3 class="widget-title">Recents</h3>
    <div class="widget-content">
      <ul>
        
          <li>
            <a href="/2023/03/22/%E6%9C%AC%E5%9C%B0%E5%9B%BE%E7%89%87/">本地图片</a>
          </li>
        
          <li>
            <a href="/2023/03/21/git%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C/">git基本操作</a>
          </li>
        
      </ul>
    </div>
  </aside>

  
    
  
    
  
</div>
      </div>
      <footer id="colophon" role="contentinfo">
    <p>&copy; 2023 Haung lixi
    All rights reserved.</p>
    <p>Powered by <a href="http://hexo.io/" target="_blank">Hexo</a></p>
</footer>
    <script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"1","bdMiniList":false,"bdPic":"","bdStyle":"2","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='/js/share.js'];</script>

<script src="/js/jquery-3.3.1.min.js"></script>


  
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">

  
<script src="/fancybox/jquery.fancybox.pack.js"></script>




<script src="/js/script.js"></script>


<script src="/js/navigation.js"></script>

<div id="bg"></div>

  </div>
</body>
</html>